﻿$(function () {
    // First file
    $("#fileData").uploadify({
        'multi': false,
        'buttonText': 'Upload Logo',
        'buttonClass': 'btn btn-choose-file',
        'width': 98,
        'height': 35,
        'fileSizeLimit': '300KB',
        'swf': '/images/uploadify.swf',
        'fileTypeDesc': 'Images',
        'fileTypeExts': '*.jpg; *.png; *.gif',
        'uploader': '/Management/PartnerList/Upload',
        'onUploadProgress': function (file) {
            $('#progress').html("File is uploading...");
        },
        'successTimeout': 180,
        'onUploadSuccess': function (file, data, response) {
            $('#progress').hide();
            var data = jQuery.parseJSON(data);
            viewModel.ImageUrl(data);
        }
    });

});

$(function () {
    // First file
    $("#fileDataBusiness").uploadify({
        'multi': false,
        'buttonText': 'Upload Logo',
        'buttonClass': 'btn btn-choose-file',
        'width': 98,
        'height': 35,
        'fileSizeLimit': '100KB',
        'swf': '/images/uploadify.swf',
        'fileTypeDesc': 'Images',
        'fileTypeExts': '*.jpg; *.png; *.gif',
        'uploader': '/MyAccount/BusinessList/Upload',
        'onUploadProgress': function (file) {
            $('#progress').html("File is uploading...");
        },
        'successTimeout': 180,
        'onUploadSuccess': function (file, data, response) {
            $('#progress').hide();
            var data = jQuery.parseJSON(data);
            viewModel.ImageUrl(data);
        }
    });

});

// Script upload archive image file
$(function () {
    $("#fileDataArchive").uploadify({
        'multi': false,
        'buttonText': 'Upload Logo',
        'buttonClass': 'btn btn-choose-file',
        'width': 98,
        'height': 35,
        'swf': '/images/uploadify.swf',
        'fileTypeDesc': 'Images',
        'fileTypeExts': '*.jpg; *.png; *.gif',
        'uploader': '/Management/ArchiveList/Upload',
        'onUploadProgress': function (file) {
            // Disabler
            $('.waiting').remove();
            $('#addyourteam').waiting();
            $('.waiting').show();
            $('#progress').css("display", "block");
        },
        'successTimeout': 5,
        'onUploadSuccess': function (file, data, response) {
            $.getJSON('/Management/ArchiveList/UploadComplete', function (data) {
                $('.waiting').hide();
                $('#progress').css("display", "none");

                // Image url
                var data = jQuery.parseJSON(data);
                viewModel.ImageUrl(data);
            });
        }
    });
});

// Script upload banner image file to server
$(function () {
    $("#fileDataBanner").uploadify({
        'multi': false,
        'buttonText': 'Upload Logo',
        'buttonClass': 'btn btn-choose-file',
        'width': 98,
        'height': 35,
        'fileSizeLimit': '300KB',
        'swf': '/images/uploadify.swf',
        'fileTypeDesc': 'Images',
        'fileTypeExts': '*.jpg; *.png; *.gif',
        'uploader': '/Management/BannerList/Upload',
        'onUploadProgress': function (file) {
            // Disabler
            $('.waiting').remove();
            $('#apps').waiting();
            $('.waiting').show();
            $('#progress').css("display", "block");
        },
        'successTimeout': 180,
        'onUploadSuccess': function (file, data, response) {
            $('.waiting').hide();
            $('#progress').css("display", "none");

            var data = jQuery.parseJSON(data);
            viewModel.ImageURL(data.FilePath);
            viewModel.ImageFileName(data.FileName);
        }
    });
});

// Script upload banner flash file to server
$(function () {
    $("#fileDataBannerFlash").uploadify({
        'multi': false,
        'buttonText': 'Upload Flash',
        'buttonClass': 'btn btn-choose-file',
        'width': 98,
        'height': 35,
        'fileSizeLimit': '600KB',
        'swf': '/images/uploadify.swf',
        'fileTypeDesc': 'Flash',
        'fileTypeExts': '*.swf',
        'uploader': '/Management/BannerList/UploadFlash',
        'onUploadProgress': function (file) {
            // Disabler
            $('.waiting').remove();
            $('#apps').waiting();
            $('.waiting').show();
            $('#progress').css("display", "block");
        },
        'successTimeout': 360,
        'onUploadSuccess': function (file, data, response) {
            $('.waiting').hide();
            $('#progress').css("display", "none");

            var data = jQuery.parseJSON(data);
            viewModel.FlashURL(data.FilePath);
            viewModel.FlashFileName(data.FileName);
        }
    });
});

// Script upload banner video file to server
$(function () {
    $("#fileDataBannerVideo").uploadify({
        'multi': false,
        'buttonText': 'Upload Video',
        'buttonClass': 'btn btn-choose-file',
        'width': 98,
        'height': 35,
        'fileSizeLimit': '3600KB',
        'swf': '/images/uploadify.swf',
        'fileTypeDesc': 'Flash',
        'fileTypeExts': '*.flv;*.wma;*.dat',
        'uploader': '/Management/BannerList/UploadVideo',
        'onUploadProgress': function (file) {
            // Disabler
            $('.waiting').remove();
            $('#apps').waiting();
            $('.waiting').show();
            $('#progress').css("display", "block");
        },
        'successTimeout': 3600,
        'onUploadSuccess': function (file, data, response) {

            $('.waiting').hide();
            $('#progress').css("display", "none");

            var data = jQuery.parseJSON(data);
            viewModel.VideoURL(data.FilePath);
            viewModel.VideoFileName(data.FileName);
        }
    });
});

// Script upload banner flash file to server
$(function () {
    $("#fileDataProduct").uploadify({
        'multi': false,
        'buttonText': 'Upload Image',
        'buttonClass': 'btn btn-choose-file',
        'width': 98,
        'height': 35,
        'fileSizeLimit': '100KB',
        'swf': '/images/uploadify.swf',
        'fileTypeDesc': 'Flash',
        'fileTypeExts': '*.jpg; *.png; *.gif',
        'uploader': '/MyAccount/ProductList/Upload',
        'onUploadProgress': function (file) {
            // Disabler
            $('.waiting').remove();
            $('#apps').waiting();
            $('.waiting').show();
            $('#progress').css("display", "block");
        },
        'successTimeout': 10,
        'onUploadSuccess': function (file, data, response) {
            $('.waiting').hide();
            $('#progress').css("display", "none");

            // Image url
            var data = jQuery.parseJSON(data);
            viewModel.ImageURL(data);
        }
    });
});